<template>
	<view class="shopList">
		<view class="title">
			{{title}}
		</view>
		<view class="list">
			<view class="card" v-for="(item,index) in list" :key="index" v-if="show?true:index<6">
				<view class="card-top">
					<image class="card-img" :src="item.spuImg" mode="aspectFill"></image>
					<view class="zekou">
						{{item | zekou}}折
					</view>
				</view>
				<view class="card-bottom">
					<view class="title">
						{{item.spuTitle}}
					</view>
					<view class="zprice">
						<view class="price">
							<text>￥</text>
							<text>{{item.spuPrice/100}}</text>
						</view>
						<image class="cart" src="../../static/card.png" mode="widthFix" @click="jiarugwBtn(item)"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="dowm" @click="show = !show" v-if="!show">
			更多推荐
			<image src="../../static/dowm.png" mode="widthFix"></image>
		</view>
	</view>
</template>

<script>
	import mixi from '../data/index.js'
	export default {
		props: {
			title: {
				type: String,
				default: ''
			},
			list: {
				type: Array,
				default: () => []
			}
		},
		data() {
			return {
				show: false
			}
		},
		mixins: [mixi],
		filters: {
			zekou(item) {
				return ((item.spuPrice / item.spuOriginalPrice) * 10).toFixed(1);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.shopList {
		width: 710rpx;
		margin: auto;
		background-color: #FFFFFF;
		border-radius: 30rpx;
		box-shadow: 5rpx 5rpx 5rpx #FFFFFF;
		padding: 20rpx 0rpx 20rpx 20rpx;
		box-sizing: border-box;

		.title {
			font-size: #333333;
			font-size: 17px;
		}

		.list {
			width: 100%;
			display: flex;
			flex-wrap: wrap;

			.card {
				width: 210rpx;
				margin: 20rpx 20rpx 0 0;
				background-color: #F7F7F7;
				box-sizing: border-box;
				border-radius: 20rpx;
				overflow: hidden;

				&-top {
					position: relative;
					padding: 10rpx 10rpx 0 10rpx;

					.zekou {
						position: absolute;
						bottom: 8rpx;
						right: 10rpx;
						background-color: #36B542;
						padding: 5rpx 15rpx;
						border-top-left-radius: 25rpx;
						color: #FFFFFF;
						font-size: 12px;
					}
				}

				&-img {
					width: 100%;
					height: 210rpx;
					border-radius: 20rpx;
				}

				&-bottom {
					padding: 5rpx 10rpx;

					.title {
						font-size: 14px;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
						-o-text-overflow: ellipsis;
					}

					.zprice {
						margin-top: 15rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;
						color: #36B542;
						padding-bottom: 10rpx;

						.price {
							text {
								&:first-child {
									font-size: 13px;
								}

								&:nth-child(2) {
									font-size: 17px;
									font-weight: bold;
								}
							}
						}

						.cart {
							width: 50rpx;
						}
					}
				}
			}
		}

		.dowm {
			padding: 30rpx 0;
			display: flex;
			justify-content: center;
			color: #666666;
			font-size: 14px;
			align-items: center;

			image {
				margin-left: 10rpx;
				width: 40rpx;
			}
		}
	}
</style>
